#include<iostream>
using namespace std;

int howMany(int money, int m, int cockMoney, int henMoney, int chickenMoney, int* cockNum, int* henNum, int* chickenNum)
{
	if (money < m || m <= 0 || cockMoney <= 0 || henMoney <= 0 || chickenMoney <= 0 || cockNum == NULL || henNum == NULL || chickenNum == NULL)return -1;
	//注意！money<m
	int key = 0;
	for (int i = 0; i <= money / cockMoney; i++)
	{
		for (int j = 0; j <= money / henMoney; j++)
		{	
			int k = m - i - j;
			if (i * cockMoney + j * henMoney + k * chickenMoney == money)
			{
				*cockNum = i;
				*henNum = j;
				*chickenNum = k;
				key = 1;
				break;
			}
		}
		if (key == 1)break;
	}
	return key;
}


//以下内容不需要提交
//
// 
// 
// 
// 
// 
//
//
int main()
{
	int money = 20;
	int m = 4;
	int m1 = 5, m2 = 3, m3 = 4;
	int a, b, c;
	int* p[3] = { &a,&b,&c };
	int cc;
	cc = howMany(money, m, m1, m2, m3, p[0], p[1], p[2]);
	return cc;
}